const wxLogin = () => {
  return new Promise((resolve, reject) => {
    wx.login({
      success: res => {
        resolve(res)
      },
      fail: err => {
        reject(err)
      }
    })
  })
}
const wxCheckAuth = () => {
  return new Promise((resolve, reject) => {
    wx.getSetting({
      success: res => {
        resolve(res.authSetting)
      },
      fail: err => {
        reject(err)
      }
    })
  })
}
const wxGetUserInfo = () => {
  return new Promise((resolve, reject) => {
    wx.getUserInfo({
      success: res => {
        if (res.errMsg === "getUserInfo:ok") {
          resolve(res)
        }
      },
      fail: err => {
        reject(err)
      }
    })
  })
}

export {
  wxLogin,
  wxGetUserInfo,
  wxCheckAuth
}